package com.ymatou.iapi.optrade.parameter.enums;

import java.util.HashMap;
import java.util.Map;

/**
 */
public enum UserTypeEnum {
	Normal(0), Seller(1), Admin(10), ;

	private static final Map<Integer, UserTypeEnum> maps = new HashMap<>();

	static {
		for (UserTypeEnum e : UserTypeEnum.values()) {
			maps.put(e.getCode(), e);
		}
	}

	private int code;

	private UserTypeEnum(int code) {
		this.code = code;
	}

	public static UserTypeEnum newInstance(String code) {
		try {
			int temp = Integer.valueOf(code);
			return maps.get(temp);
		} catch (NumberFormatException e) {
			return UserTypeEnum.valueOf(code);
		}
	}

	public int getCode() {
		return code;
	}
}
